package org.emet.service;
import org.emet.dao.RefuelHistDao;
import org.emet.entity.biz.RefuelHist;
import org.emet.jee.BusinessException;
import org.emet.jee.core.dao.Page;
import org.emet.service.dto.RefuelHistCriteria;
import org.hibernate.ObjectNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
@RemotingDestination
public class RefuelHistService {
@Autowired
private RefuelHistDao refuelHistDao;
private static Logger logger = LoggerFactory.getLogger(RefuelHistService.class);
public void save(RefuelHist entity) {
try {
refuelHistDao.save(entity);
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new BusinessException("发生异常!");
}
}
	@Transactional(readOnly = true)
public RefuelHist get(Long id) {
try {
return refuelHistDao.get(id);
} catch (ObjectNotFoundException e) {
logger.error(e.getMessage(), e);
throw new BusinessException("发生异常!");
}
}
public void del(Long... ids) {
for (Long id : ids) {
if (notExist(id)) {
continue;
}
try {
refuelHistDao.delete(id);
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new BusinessException("发生异常!");
}
}
}
private boolean notExist(Long id) {
return get(id) == null;
}
	@Transactional(readOnly = true)
public Page<RefuelHist> search(Page<RefuelHist> page, RefuelHistCriteria criteria) {
try {return 
refuelHistDao.search(page, criteria);
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new BusinessException("发生异常!");
}
}
}
